package come.pbms.nursing.controller;

import come.pbms.common.core.controller.BaseController;
import come.pbms.common.core.domain.AjaxResult;
import come.pbms.common.core.domain.R;
import come.pbms.nursing.domain.NursingServe;
import come.pbms.nursing.service.NursingService;
import come.pbms.nursing.vo.NursingServePageVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/api/value-added-services")
public class NursingController extends BaseController {

    @Autowired
    private NursingService nursingService;

    @GetMapping
    public R<NursingServePageVO> getList(@RequestParam(defaultValue = "1") Integer pageNum,
                                         @RequestParam(defaultValue = "10") Integer pageSize,
                                         Integer status,
                                         String serviceName)
    {
        NursingServePageVO nursingServePageVO =nursingService.getList(pageNum,pageSize,status,serviceName);
        return R.ok(nursingServePageVO);
    }

    @PostMapping
    public AjaxResult add(@RequestBody NursingServe nursingServe){
        ;
        return toAjax(nursingService.insertNursingServe(nursingServe));
    }

    @GetMapping("/{serviceId}")
    public R<NursingServe> getById(@PathVariable Integer serviceId){
        return R.ok(nursingService.getById(serviceId));
    }

    @PutMapping("/{serviceId}")
    public AjaxResult update(@PathVariable Integer serviceId,
                             @RequestBody NursingServe nursingServe){
        nursingServe.setServiceId(serviceId);
        return toAjax(nursingService.update(nursingServe));
    }
    @DeleteMapping("/{serviceId}")
    public AjaxResult deleteById(@PathVariable Integer serviceId){
        return toAjax(nursingService.deleteById(serviceId));
    }
}
